package com.qin.mall.controller.ordercontroller;

import com.qin.mall.common.api.CommonResult;
import com.qin.mall.common.api.MyBatisPlusPage;
import com.qin.mall.domain.OmsOrderReturnReason;
import com.qin.mall.openfeign.order.OmsOrderReturnReasonFeigin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Leisure
 * create 2022 2022/11/22 14:04
 **/
@RestController
@RequestMapping("/returnReason")
public class OrderReturnReasonController {
    
    @Autowired
    private OmsOrderReturnReasonFeigin orderReturnReasonFeigin;

    /**
     * 分页获取退货原因
     */
    @GetMapping("/list")
    @ResponseBody
    public CommonResult<MyBatisPlusPage<OmsOrderReturnReason>> list(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                                    @RequestParam(value = "pageSize",defaultValue = "5") Integer pageSize){
        CommonResult<MyBatisPlusPage<OmsOrderReturnReason>> list = orderReturnReasonFeigin.list(pageNum, pageSize);
        return list;
    }

    /**
     * 获取单个退货原因详情信息
     */
    @GetMapping("/{id}")
    public CommonResult<OmsOrderReturnReason> getItem(@PathVariable Long id){
        CommonResult<OmsOrderReturnReason> count = orderReturnReasonFeigin.getItem(id);
        return count;
    }

    /**
     * 修改退货原因
     */
    @PostMapping("/update/{id}")
    public CommonResult update(@PathVariable Long id,
                               @RequestBody OmsOrderReturnReason returnReason){
        CommonResult count = orderReturnReasonFeigin.update(id, returnReason);
        return count;
    }

    /**
     * 批量修改退货原因状态
     */
    @PostMapping("/update/status")
    public CommonResult updateStatus(@RequestParam("status") Integer status,
                                     @RequestParam("ids") List<Long> ids){
        CommonResult count = orderReturnReasonFeigin.updateStatus(status, ids);
        return count;
    }

    /**
     *添加订单原因
     */
    @PostMapping("/create")
    public CommonResult create(@RequestBody OmsOrderReturnReason returnReason){
        CommonResult count = orderReturnReasonFeigin.create(returnReason);
        return count;
    }

    /**
     * 批量删除退货原因
     */
    @PostMapping("/delete")
    public CommonResult delete(@RequestParam("ids") List<Long> ids){
        CommonResult count = orderReturnReasonFeigin.delete(ids);
        return count;
    }
}
